﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace RestfulApi.Filters
{
    public class MyAuthorizationFilterAttribute : Attribute, IAuthorizationFilter
    {
        public MyAuthorizationFilterAttribute(ILogger<MyAuthorizationFilterAttribute> logger)
        {
            Logger = logger;
        }

        public ILogger<MyAuthorizationFilterAttribute> Logger { get; }

        public void OnAuthorization(AuthorizationFilterContext context)
        {
            //Logger.LogInformation("OnAuthorization executes.");
            //throw new Exception("OnAuthorization");  不能
        }
    }
}
